/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: lenovo
 * Date: 2022-09-21
 * Time: 8:16
 */

/**
 * 无返回值函数式接口
 */









/**
 * 有返回值函数式接口
 */
//无返回值无参数
@FunctionalInterface
interface NoParameterNoReturn {
    void test();
}
//无返回值一个参数
@FunctionalInterface
interface OneParameterNoReturn {
    void test(int a);
}
//无返回值多个参数
@FunctionalInterface
interface MoreParameterNoReturn {
    void test(int a,int b);
}


//有返回值无参数
@FunctionalInterface
interface NoParameterReturn {
    int test();
}
//有返回值一个参数
@FunctionalInterface
interface OneParameterReturn {
    int test(int a);
}
//有返回值多参数
@FunctionalInterface
interface MoreParameterReturn {
    int test(int a,int b);
}
public class simpleDemo {
    public static void main(String[] args) {
        int szie = 10;
        MoreParameterReturn moreParameterReturn = (x,y)->
        {
            System.out.println(x+y);
            return szie;
        };
        System.out.println(moreParameterReturn.test(10,20));
    }












    public static void main5(String[] args) {
        OneParameterReturn oneParameterReturn = x->2*x;
        System.out.println(oneParameterReturn.test(5));
    }















    public static void main4(String[] args) {
        NoParameterReturn noParameterReturn =()->{return 10;};
        System.out.println(noParameterReturn.test());
        System.out.println("简化");
        NoParameterReturn noParameterReturn1 =()-> 10;
        System.out.println(noParameterReturn1.test());


    }














    public static void main3(String[] args) {
        MoreParameterNoReturn moreParameterNoReturn = (a,b)-> System.out.println(a+b);
        moreParameterNoReturn.test(10,20);
        MoreParameterNoReturn moreParameterNoReturn2 = (a, b)-> System.out.println(a+b);
    }













    public static void main2(String[] args) {
        OneParameterNoReturn oneParameterNoReturn = (int x)->{
            System.out.println(x);
        };
        oneParameterNoReturn.test(150);
        System.out.println("简化");
        OneParameterNoReturn oneParameterNoReturn1 = (x)-> System.out.println(x);
        oneParameterNoReturn1.test(160);
        OneParameterNoReturn oneParameterNoReturn2 = x-> System.out.println(x);
        oneParameterNoReturn2.test(170);
        OneParameterNoReturn oneParameterNoReturn3 = System.out::println;
    }










    public static void main1(String[] args) {
        NoParameterNoReturn  noParameterNoReturn = new NoParameterNoReturn() {
            @Override
            public void test() {
                System.out.println("测试一下");
            }
        };
        noParameterNoReturn.test();
        NoParameterNoReturn noParameterNoReturn1 = ()->
        {System.out.println("lambda测试一下");
            System.out.println("lambda测试第二次");};
        noParameterNoReturn1.test();
    }
}
